//
//  NSBundle+BaseTookKit.m
//  BaseToolsKit
//
//  Created by zyming on 2022/8/23.
//

#import "NSBundle+BaseTookKit.h"
#import "BaseToolsKit.h"

NSString *const kQMUIResourcesBundleName = @"BaseTookKit";
@implementation NSBundle (BaseTookKit)

+ (UIImage *)GDbaseImageForBundle:(NSString *)imageName
{
    NSBundle *resourceBundle = [NSBundle GDBaseResourceBundle];
    UIImage *image = [UIImage imageNamed:imageName
                                inBundle:resourceBundle
           compatibleWithTraitCollection:nil];
    
    return image;
}

+ (NSBundle *)GDBaseResourceBundle
{
    NSBundle *bundle = [NSBundle bundleForClass:NSClassFromString(@"AccountModel")];
    NSString *bundleName = bundle.infoDictionary[@"CFBundleName"];
    NSURL *bundleURL = [bundle URLForResource:bundleName withExtension:@"bundle"];
    if (!bundleURL) {
        bundleName = @"BaseToolsKit";
        bundleURL = [bundle URLForResource:bundleName withExtension:@"bundle"];
    }
    NSBundle *resourceBundle = [NSBundle bundleWithURL:bundleURL];
    return resourceBundle;
}

+ (NSBundle *)GDBaseLanguageBundle{
    
    NSString *bundlePath = @"zh-Hant";//繁体
    if ([kAppLanguage hasPrefix:@"en"]) {
        bundlePath = @"en";//英文
    }else if ([kAppLanguage hasPrefix:@"zh-Hans"]){
        bundlePath = @"zh-Hans";//简体
    }
    NSString *path = [[NSBundle GDBaseResourceBundle] pathForResource:bundlePath ofType:@"lproj"];
    return [NSBundle bundleWithPath:path];
}

@end
